package org.example.reactive.demo1.api;

import lombok.RequiredArgsConstructor;
import org.example.reactive.demo1.entity.Employer;
import org.example.reactive.demo1.repository.EmployerRepository;
import org.springframework.data.mongodb.core.ReactiveMongoOperations;
import org.springframework.data.mongodb.core.query.BasicQuery;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
 * @author Gong.Yang
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/employer")
public class EmployerApi {
    private final EmployerRepository employerRepository;
    private final ReactiveMongoOperations operations;

    @PostMapping
    public Mono<Employer> create(@RequestBody Employer employer) {
        return employerRepository.insert(employer);
    }

    @GetMapping
    public Flux<Employer> findList() {
        return employerRepository.findAll();
    }
}
